package com.gzy.rpsm_admin.controller;

import com.gzy.rpsm_admin.pojo.PageResult;
import com.gzy.rpsm_admin.pojo.ResponsePojo;
import com.gzy.rpsm_admin.pojo.Room;
import com.gzy.rpsm_admin.service.RoomService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags="房间相关接口")
public class RoomController {
    @Autowired
    private RoomService roomService;

    @GetMapping("/page/room")
    @ApiOperation( value="查询房间分页信息",
            response = Room.class,
            responseContainer = "list",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name="current",value = "当前页数 ",defaultValue = "1",dataType = "Integer",paramType = "query"),
            @ApiImplicitParam(name="size",value = "页面行数",dataType = "Integer",paramType = "query",defaultValue = "10"),
            @ApiImplicitParam(name="number",value="房间编号",dataType = "String",paramType = "query")
    })
    public ResponsePojo<PageResult<Room>> pageOfRoom(
            @RequestParam(defaultValue = "1") Integer current,
            @RequestParam(defaultValue = "10") Integer size,
            String number){
        PageResult<Room> rooms = roomService.pageOfRoom(current,size,number);
        return ResponsePojo.success(rooms);
    }
}